open(BUFF,"gunzip -c  /data4/bsi/bioinf_ext2/s109990/m081429_mesa/FINAL_MERGING/DB_DIR/b137_SNPChrPosOnRef.bcp.gz |") or die "no file found\n";
while(<BUFF>)
{
	chomp($_);
	@array=split("\t",$_);
	$array[1] =~ s/X/23/g;
	$array[1] =~ s/Y/24/g;
	$array[1] =~ s/M/26/g;
	$array[2] = $array[2]+1;
	$hash{"$array[1] $array[2]"}="rs".$array[0];
}
open(BUFF,"/data4/bsi/bioinf_ext2/s109990/m081429_mesa/FINAL_MERGING/EXOME/Exome_final.tped");
open(WRBUFF,">/data4/bsi/bioinf_ext2/s109990/m081429_mesa/FINAL_MERGING/EXOME/Exome_final_updated_rsid.tped");
while(<BUFF>)
{
	chomp($_);
	@array=split(" ",$_);
	if(exists($hash{"$array[0] $array[3]"}))
	{
		$array[1] = $hash{"$array[0] $array[3]"};
	}
	else
	{
		$array[1] = "$array[0]_$array[3]";
	}
	$_ = join(" ",@array);
	print WRBUFF $_."\n";
}
